package com.woyou.bean;

import java.util.ArrayList;
import java.util.List;

import com.woyou.utils.ParseUtils;

/**
 * 商品model
 * 
 * @author lenovo
 * 
 */
@SuppressWarnings("serial")
public class ChosenGoods extends SuperBean implements IChoose{
	
	
	public ChosenGoods(Goods parent) {
		this.parent = parent;
		this.gId = parent.getgId();
		this.price = parent.getPrice();
		this.ids = parent.getgId();
	}

	/**
	 * 来源商品
	 */
	private Goods parent;
	
	private String gId;

	/**
	 * 选中的option和subGoods id的集合字符串
	 */
	private String ids;
	/**
	 * chosenGList属性列表与chosenOption子商品列表名称的串连
	 */
	private String names;
	/**
	 * 单价
	 */
	private float price;

	/**
	 * 已选择的份数（购物车）
	 */
	private int chosenNum = 0;
	
	public String getgId() {
		return gId;
	}
	public void setgId(String gId) {
		this.gId = gId;
	}
	

	public Goods getParent() {
		return parent;
	}
	public void setParent(Goods parent) {
		this.parent = parent;
	}
	
	/**
	 * 被选中的子商品列表
	 */
	private List<SubGoods> chosenSGList = new ArrayList<SubGoods>();
	/**
	 * 被选中的属性列表
	 */
	private List<Option> chosenOptList = new ArrayList<Option>();
	
	public String getNames() {
		return names;
	}
	public void setNames(String names) {
		this.names = names;
	}
	public String getIds() {
		return ids;
	}
	public void setIds(String ids) {
		this.ids = ids;
	}
	public float getPrice() {
		float formatPrice = ParseUtils.formatPrice1(price);
		return formatPrice;
	}
	public void setPrice(float price) {
		this.price = price;
	}
	public int getChosenNum() {
		return chosenNum;
	}
	public void setChosenNum(int chosenNum) {
		this.chosenNum = chosenNum;
	}
	public List<SubGoods> getChosenSGList() {
		return chosenSGList;
	}
	public void setChosenSGList(List<SubGoods> chosenSGList) {
		this.chosenSGList = chosenSGList;
	}
	
    @Override
	public int hashCode() {
		final int prime = 31;
		int result = 1;
		result = prime * result + ((gId == null) ? 0 : gId.hashCode());
		result = prime * result + ((ids == null) ? 0 : ids.hashCode());
		return result;
	}
    
	@Override
	public boolean equals(Object obj) {
		if (this == obj)
			return true;
		if (obj == null)
			return false;
		if (getClass() != obj.getClass())
			return false;
		ChosenGoods other = (ChosenGoods) obj;
		if (gId == null) {
			if (other.gId != null)
				return false;
		} else if (!gId.equals(other.gId))
			return false;
		if (ids == null) {
			if (other.ids != null)
				return false;
		} else if (!ids.equals(other.ids))
			return false;
		return true;
	}
	
	public List<Option> getChosenOptList() {
		return chosenOptList;
	}
	
	public void setChosenOptList(List<Option> chosenOptList) {
		this.chosenOptList = chosenOptList;
	}
	@Override
	public void setgName(String name) {
		parent.setgName(name);		
	}
	@Override
	public String getgName() {
		return parent.getgName();
	}
	@Override
	public String getUnit() {
		// TODO Auto-generated method stub
		return parent.getUnit();
	}
	@Override
	public void setUnit(String unit) {
		parent.setUnit(unit);
		
	}
}
